
import HighPrecisionThreatAssessment
def performance_test():
    """性能测试函数"""
    # 创建测试数据
    class TestPlatform:
        def __init__(self, plat_id, fLat, fLon, fHeight, fSpeed, fDir):
            self.plat_id = plat_id
            self.fLat = fLat
            self.fLon = fLon
            self.fHeight = fHeight
            self.fSpeed = fSpeed
            self.fDir = fDir
            self.weapons = []
    
    # 创建轰炸机
    bomber = TestPlatform("bomber", 39.9, 116.4, 10000, 250, 45)
    
    # 创建多个敌机（模拟10个目标）
    enemy_list = []
    for i in range(10):
        enemy = TestPlatform(
            f"enemy_{i}",
            39.9 + (i-5)*0.01,  # 分散在轰炸机周围
            116.4 + (i-5)*0.01,
            8000 + i*200,
            200 + i*20,
            30 + i*10
        )
        enemy_list.append(enemy)
    
    # 测试不同优化级别
    optimization_levels = ['low', 'medium', 'high']
    
    for level in optimization_levels:
        print(f"\n{'='*50}")
        print(f"测试优化级别: {level}")
        print(f"{'='*50}")
        
        system = HighPrecisionThreatAssessment(optimization_level=level)
        
        # 测试不同计算方法
        methods = ['single_thread', 'multi_thread', 'parallel', 'auto']
        
        for method in methods:
            print(f"\n--- 计算方法: {method} ---")
            try:
                results, processing_time = system.calculate_threats(bomber, enemy_list, method=method)
                print(f"处理时间: {processing_time:.2f} ms")
            except Exception as e:
                print(f"错误: {e}")

if __name__ == "__main__":
    performance_test()